using System;
using UnityEngine;
using UnityEngine.UI;
public class Setting_UI : MonoBehaviour ,IPage
{
    public Button btn_Continue,btn_Restart, btn_Quit;
    public Slider sld_voice;
    private void OnEnable()
    {
        btn_Continue.onClick.AddListener(Continue);
        btn_Restart.onClick.AddListener(Restart);
        btn_Quit.onClick.AddListener(BackToMenu);
        sld_voice.onValueChanged.AddListener(SetVolume);
    }

    private void OnDisable()
    {
        btn_Continue.onClick.RemoveListener(Continue);
        btn_Quit.onClick.RemoveListener(BackToMenu);
        btn_Restart.onClick.RemoveListener(Restart);
        sld_voice.onValueChanged.RemoveListener(SetVolume);
    }
    private void SetVolume(float arg0)
    {
        AudioManager.Instance.SetVolume(arg0);
    }
    private void Quit()
    {
        Application.Quit();
    }

    private void BackToMenu()
    {
        GameManager.Instance.BackToMenu();
    }

    private void Restart()
    {
        if (GameManager.Instance != null)
        {
            GameManager.Instance.GameRestart();
        }
    }

    private void Continue()
    {
        if(UIController.instance != null)
        {
            UIController.instance.ClosePage(0);
        }
    }

    public void OpenPage()
    {
        if(GameManager.Instance != null)
        {
            GameManager.Instance.GamePause();
        }
    }

    public void ClosePage()
    {
        if (GameManager.Instance != null)
        {
            GameManager.Instance.GameContinue();
        }
    }
}
